<script src="__PUBLIC__/js/artDialog/jquery.artDialog.js?skin=default"></script>
<script src="__PUBLIC__/js/artDialog/plugins/iframeTools.js"></script>
<style type="text/css">
a.a_upload,a.a_choose{
	border:1px solid #3d810c;
	box-shadow:0 1px #cccccc;
	-moz-box-shadow:0 1px #cccccc;
	-webkit-box-shadow:0 1px #cccccc;
	cursor:pointer; 
	display: inline-block;
	text-align: center;
	vertical-align:bottom;
	overflow:visible;
	border-radius:3px;
	-moz-border-radius:3px;
	-webkit-border-radius:3px;
	vertical-align:middle;
	background-color: #f1f1f1;
	background-image: -webkit-linear-gradient(bottom, #ccc 0%, #e5e5e5 3%, #fff 97%, #fff 100%);
	background-image: -moz-linear-gradient(bottom, #ccc 0%, #e5e5e5 3%, #fff 97%, #fff 100%);
	background-image: -ms-linear-gradient(bottom, #ccc 0%, #e5e5e5 3%, #fff 97%, #fff 100%);
	color: #000;
	border:1px solid #aaa;
	padding:2px 8px 2px 8px;
	text-shadow: 0 1px #ffffff;
	font-size: 14px;
	line-height: 1.5;
}
</style>
<div class="pd-20">
    <form action="" method="post" class="form form-horizontal" action="{:U("Admin/Order/addFood")}">
    	<input type="hidden" name="id" value="{$food['id']}">
        <div class="row cl">
        	<label class="form-label col-3"><span class="c-red"></span>{:C('pom_admin_product_name')}名</label>
            <div class="col-6">
	            <input type="text" class="input-text" value="{$food['name']}" placeholder="" id="name" name="name" datatype="*2-16" nullmsg="">
            </div>
            <div class="col-3"></div>
        </div>
        <div class="row cl">
        	<label class="form-label col-3"><span class="c-red"></span>菜品描述</label>
            <div class="col-6">
	            <textarea rows="3" cols="52" name="des" id="des">{$food['des']}</textarea>
            </div>
            <div class="col-3"></div>
        </div>
        <div class="row cl">
        	<label class="form-label col-3"><span class="c-red"></span>分类</label>
            <div class="col-6">
            	<select onchange="changesort(this);" id="state-sel" class="input-text">
            		<volist name="sorts" id="sort" key="k">
		        		<option value="{$key}">{$sort}</option>
            		</volist>
	        	</select>
	            <input type="hidden" value="{$food['sid']}" placeholder="" id="sid" name="sid" datatype="*2-16" nullmsg="">
            </div>
            <div class="col-3"></div>
        </div>
        <div class="row cl">
        	<label class="form-label col-3"><span class="c-red"></span>价格</label>
            <div class="col-6">
	            <input type="text" class="input-text" value="{$food['price']}" placeholder="" id="price" name="price" datatype="*2-16" nullmsg="">
            </div>
            <div class="col-3"></div>
        </div>
        <div class="row cl">
        	<label class="form-label col-3"><span class="c-red"></span>计量单位</label>
            <div class="col-6">
	            <input type="text" class="input-text" value="{$food['unit']}" placeholder="" id="unit" name="unit" datatype="*2-16" nullmsg="">
            </div>
            <div class="col-3"></div>
        </div>
        <div class="row cl">
        	<label class="form-label col-3"><span class="c-red"></span>库存</label>
            <div class="col-6">
	            <input type="text" class="input-text" value="{$food['instock']}" placeholder="" id="instock" name="instock" datatype="*2-16" nullmsg="">
            </div>
            <div class="col-3"></div>
        </div>
        <div class="row cl">
        	<label class="form-label col-3"><span class="c-red"></span>图片</label>
            <div class="col-6">
	            <!--input type="text" name="image" value="{$food.image}" class="px" id="pic"  step="width:400px;"-->
	            <input type="text" name="image" value="{$food.image}" id="pic" datatype="*2-16" class="input-text" nullmsg="">
	            <script src="__PUBLIC__/js/upyun.js"></script>
            </div>
            <div class="col-3"><a href="###" onclick="upyunPicUpload('pic', 500, 500,'food')" class="a_upload">上传</a>
	            <a href="###" onclick="viewImg('pic')">预览</a></div>
        </div>
        <div class="row cl">
        	<label class="form-label col-3"><span class="c-red"></span>排序</label>
            <div class="col-6">
	            <input type="text" class="input-text" value="{$food.sort}" placeholder="" id="sort" name="sort" datatype="*2-16" nullmsg="">
            </div>
            <div class="col-3"></div>
        </div>
        <div class="row cl">
            <div class="col-9 col-offset-3">
                <input name="fomr-add" class="btn btn-success " type="submit" value="&nbsp;提交&nbsp;">
            </div>
        </div>
    </form>
</div>
<script>
// 适配3.2
var site_url = '{:U("Admin/Upyun/upload", array(), false)}';
//用户-编辑
function manage_edit(title, url, id, w, h, pc) {
	var height = 440 + (h-1)*31;
	if(pc == null) {
		height -= 31;
	}
    layer_show(title, url, w, height);
}

function changesort(obj) {
	//window.location.href="/index.php?g=Admin&m=Order&a=showAll&state="+$(obj).val();
	var sortid = $(obj).val();
	$('#sid').val(sortid);
}

$(document).ready(function(){
	<if condition="$food neq null">
	var sid = {$sid};
	$("option").each(function(){
		var opt_val = $(this).val(); 
		if(opt_val == sid) {
			$(this).attr("selected",'');
		}
	});
	<else />
	var firstSort = $('#state-sel').children().first();
	firstSort.attr("selected",'');
	var sid = firstSort.val();
	$('#sid').val(sid);
	</if>
});
</script>